import cv2 as cv
import numpy as np

def img_resize(in_img,rate=1):
    tmp_img=in_img.copy()
    tmp_img=cv.resize(tmp_img,(int(in_img.shape[1]/rate),int(in_img.shape[0]/rate)))
    return tmp_img

img=cv.imread('image/test/0.jpg')
# cv.imshow('img',img_resize(img,1))

hsv=cv.cvtColor(img,cv.COLOR_BGR2HSV) #得到HSV

# cv.imshow('hsv',img_resize(hsv))
img_with_green=cv.inRange(hsv,np.array([35,43,46]),np.array([77,255,255])) #现在人被扣了，保留了背景绿幕
img_without_green=cv.bitwise_not(img_with_green)  #反转
img_without_green=cv.bitwise_and(img,img,mask=img_without_green)



cv.imshow('no_green',img_without_green)  #



# cv.waitKey()
# cv.destroyAllWindows()



